window.__require = function e(t, n, r) {
  function s(o, u) {
    if (!n[o]) {
      if (!t[o]) {
        var b = o.split("/");
        b = b[b.length - 1];
        if (!t[b]) {
          var a = "function" == typeof __require && __require;
          if (!u && a) return a(b, !0);
          if (i) return i(b, !0);
          throw new Error("Cannot find module '" + o + "'");
        }
        o = b;
      }
      var f = n[o] = {
        exports: {}
      };
      t[o][0].call(f.exports, function(e) {
        var n = t[o][1][e];
        return s(n || e);
      }, f, f.exports, e, t, n, r);
    }
    return n[o].exports;
  }
  var i = "function" == typeof __require && __require;
  for (var o = 0; o < r.length; o++) s(r[o]);
  return s;
}({
  Game: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "d5900BFcZFC9rXr4eUIX15O", "Game");
    "use strict";
    var __extends = this && this.__extends || function() {
      var extendStatics = function(d, b) {
        extendStatics = Object.setPrototypeOf || {
          __proto__: []
        } instanceof Array && function(d, b) {
          d.__proto__ = b;
        } || function(d, b) {
          for (var p in b) Object.prototype.hasOwnProperty.call(b, p) && (d[p] = b[p]);
        };
        return extendStatics(d, b);
      };
      return function(d, b) {
        extendStatics(d, b);
        function __() {
          this.constructor = d;
        }
        d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __());
      };
    }();
    var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
      var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
      if ("object" === typeof Reflect && "function" === typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
      return c > 3 && r && Object.defineProperty(target, key, r), r;
    };
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var tvEvent_1 = require("./tvEvent");
    var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
    var DIR;
    (function(DIR) {
      DIR[DIR["NONE"] = 0] = "NONE";
      DIR[DIR["LEFT"] = 1] = "LEFT";
      DIR[DIR["RIGHT"] = 2] = "RIGHT";
      DIR[DIR["UP"] = 3] = "UP";
      DIR[DIR["DOWN"] = 4] = "DOWN";
    })(DIR || (DIR = {}));
    var speed = 20;
    var Game = function(_super) {
      __extends(Game, _super);
      function Game() {
        return null !== _super && _super.apply(this, arguments) || this;
      }
      Game.prototype.onLoad = function() {
        this.initMyEventListener();
        cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.handleKey, this);
        this.hero.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
        this.hero.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
        this.hero.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
        console.log("bgm:", this.bgm);
        this.bgm.play();
      };
      Game.prototype.onDestroy = function() {
        tvEvent_1.tv.EventMgr.off("MYEVENT", this.onMyEvent, this);
      };
      Game.prototype.initMyEventListener = function() {
        tvEvent_1.tv.EventMgr.init();
        tvEvent_1.tv.EventMgr.on(tvEvent_1.tv.EventType.TOUCH_START, this.myTouchStart, this);
        tvEvent_1.tv.EventMgr.on(tvEvent_1.tv.EventType.TOUCH_MOVE, this.myTouchMove, this);
        tvEvent_1.tv.EventMgr.on(tvEvent_1.tv.EventType.TOUCH_END, this.myTouchEnd, this);
        tvEvent_1.tv.EventMgr.on(tvEvent_1.tv.EventType.JOYSTICK_DOWN, this.myJoyStickDown, this);
        tvEvent_1.tv.EventMgr.on(tvEvent_1.tv.EventType.JOYSTICK_MOVE, this.myJoyStickMove, this);
        tvEvent_1.tv.EventMgr.on(tvEvent_1.tv.EventType.JOYSTICK_UP, this.myJoyStickUp, this);
        tvEvent_1.tv.EventMgr.on(tvEvent_1.tv.EventType.BUTTON_CLICK, this.myBtnClick, this);
        tvEvent_1.tv.EventMgr.on("MYEVENT", this.onMyEvent, this);
      };
      Game.prototype.onMyEvent = function(e) {
        console.log("myEvent:", e);
      };
      Game.prototype.myBtnClick = function(btnId) {
        console.log("myBtnClick:", btnId);
      };
      Game.prototype.myJoyStickDown = function(e) {
        console.log("myJoyStickDown", e);
      };
      Game.prototype.myJoyStickMove = function(dirx, diry) {
        console.log("myJoyStickDown", dirx, diry);
        var x = this.hero.x + speed * dirx;
        var y = this.hero.y + speed * diry;
        this.moveHero2(x, y);
      };
      Game.prototype.myJoyStickUp = function(e) {
        console.log("myJoyStickDown", e);
      };
      Game.prototype.myTouchStart = function(e) {
        console.log("myTouchStart", e);
      };
      Game.prototype.myTouchMove = function(x, y) {
        console.log("myTouchMove", x, y);
        var pos = cc.v2(x, y);
        this.hero.setPosition(pos);
      };
      Game.prototype.myTouchEnd = function(e) {
        console.log("myTouchEnd", e);
      };
      Game.prototype.start = function() {};
      Game.prototype.handleKey = function(e) {
        switch (e.keyCode) {
         case cc.macro.KEY.left:
          this.moveHero(DIR.LEFT);
          break;

         case cc.macro.KEY.up:
          this.moveHero(DIR.UP);
          break;

         case cc.macro.KEY.right:
          this.moveHero(DIR.RIGHT);
          break;

         case cc.macro.KEY.down:
          this.moveHero(DIR.DOWN);
        }
      };
      Game.prototype.onTouchStart = function(e) {
        console.log("touchStart", e);
      };
      Game.prototype.onTouchEnd = function(e) {
        console.log("touchEnd", e);
      };
      Game.prototype.onTouchMove = function(e) {
        console.log("touchMove", e);
        console.log("before pos", this.hero.position.x, this.hero.position.y);
        var d = e.touch.getDelta();
        console.log("touc delta", d);
        var x = this.hero.position.x + d.x;
        var y = this.hero.position.y + d.y;
        console.log("pos", x, y);
        this.hero.setPosition(x, y);
      };
      Game.prototype.moveHero = function(to) {
        var x = this.hero.x;
        var y = this.hero.y;
        switch (to) {
         case DIR.LEFT:
          x -= speed;
          break;

         case DIR.RIGHT:
          x += speed;
          break;

         case DIR.UP:
          y += speed;
          break;

         case DIR.DOWN:
          y -= speed;
        }
        this.moveHero2(x, y);
      };
      Game.prototype.moveHero2 = function(x, y) {
        var screen = cc.winSize;
        var maxWidth = screen.width / 2 - this.hero.width / 2;
        var maxHeight = screen.height / 2 - this.hero.height / 2;
        x < -maxWidth ? x = -maxWidth : x > maxWidth && (x = maxWidth);
        y < -maxHeight ? y = -maxHeight : y > maxHeight && (y = maxHeight);
        this.hero.setPosition(x, y);
      };
      Game.prototype.testClientWs = function() {
        var androidJs = tvEvent_1.tv.getAndroidJs();
        androidJs ? androidJs.send2Phone("message from game") : console.log("not in tv app");
      };
      __decorate([ property({
        type: cc.Node
      }) ], Game.prototype, "hero", void 0);
      __decorate([ property({
        type: cc.AudioSource
      }) ], Game.prototype, "bgm", void 0);
      Game = __decorate([ ccclass ], Game);
      return Game;
    }(cc.Component);
    exports.default = Game;
    cc._RF.pop();
  }, {
    "./tvEvent": "tvEvent"
  } ],
  MyTest: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "361dfNGmpBCXbgxfklusB6e", "MyTest");
    "use strict";
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var MyTest = function() {
      function MyTest() {}
      MyTest.prototype.log = function(msg) {
        console.log("MyTest:", msg);
      };
      MyTest.instance = new MyTest();
      return MyTest;
    }();
    exports.default = MyTest;
    cc._RF.pop();
  }, {} ],
  myWin: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "f0daecr5E9DmqTf5vQbxpJE", "myWin");
    "use strict";
    exports.__esModule = true;
    exports.addProp = addProp;
    exports.showProp = showProp;
    var _MyTest = _interopRequireDefault(require("./MyTest"));
    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : {
        default: obj
      };
    }
    function addProp() {
      window.MY_EVENT_MANAGER = _MyTest["default"].instance;
    }
    function showProp() {
      console.log(window.MY_EVENT_MANAGER);
    }
    cc._RF.pop();
  }, {
    "./MyTest": "MyTest"
  } ],
  tvEvent: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "14f1eQfxYNGxpHkU0b9UDNC", "tvEvent");
    "use strict";
    var __extends = this && this.__extends || function() {
      var extendStatics = function(d, b) {
        extendStatics = Object.setPrototypeOf || {
          __proto__: []
        } instanceof Array && function(d, b) {
          d.__proto__ = b;
        } || function(d, b) {
          for (var p in b) Object.prototype.hasOwnProperty.call(b, p) && (d[p] = b[p]);
        };
        return extendStatics(d, b);
      };
      return function(d, b) {
        extendStatics(d, b);
        function __() {
          this.constructor = d;
        }
        d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __());
      };
    }();
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.tv = void 0;
    var tv;
    (function(tv) {
      var EventType;
      (function(EventType) {
        EventType["JOYSTICK_DOWN"] = "JSD";
        EventType["JOYSTICK_UP"] = "JSU";
        EventType["JOYSTICK_MOVE"] = "JSM";
        EventType["BUTTON_CLICK"] = "Btn";
        EventType["TOUCH_START"] = "THS";
        EventType["TOUCH_END"] = "THE";
        EventType["TOUCH_MOVE"] = "THM";
        EventType["TOUCH_CANCEL"] = "THC";
      })(EventType = tv.EventType || (tv.EventType = {}));
      var ButtonType;
      (function(ButtonType) {
        ButtonType[ButtonType["BTN_OK"] = 1] = "BTN_OK";
        ButtonType[ButtonType["BTN_CANCEL"] = 2] = "BTN_CANCEL";
        ButtonType[ButtonType["BTN_1"] = 11] = "BTN_1";
        ButtonType[ButtonType["BTN_2"] = 12] = "BTN_2";
        ButtonType[ButtonType["BTN_3"] = 13] = "BTN_3";
        ButtonType[ButtonType["BTN_4"] = 14] = "BTN_4";
      })(ButtonType = tv.ButtonType || (tv.ButtonType = {}));
      function getAndroidJs() {
        try {
          if (androidJs) {
            console.log("find androidJs");
            return androidJs;
          }
        } catch (e) {
          console.log("not find androidJs");
          return null;
        }
      }
      tv.getAndroidJs = getAndroidJs;
      var EventMgr = function(_super) {
        __extends(EventMgr, _super);
        function EventMgr() {
          return null !== _super && _super.apply(this, arguments) || this;
        }
        EventMgr.GetInstance = function() {
          null == EventMgr._instace && (EventMgr._instace = new EventMgr());
          return EventMgr._instace;
        };
        EventMgr.init = function() {
          var mywin = window;
          mywin.MY_EVENT_MANAGER = EventMgr.GetInstance();
        };
        EventMgr.on = function(type, callback, target) {
          this.GetInstance().on(type, callback, target);
        };
        EventMgr.once = function(type, callback, target) {
          this.GetInstance().once(type, callback, target);
        };
        EventMgr.off = function(type, callback, target) {
          this.GetInstance().off(type, callback, target);
        };
        EventMgr.targetOff = function(target) {
          this.GetInstance().targetOff(target);
        };
        EventMgr.emit = function(type, arg1, arg2, arg3, arg4, arg5) {
          console.log("emit", type);
          this.GetInstance().emit(type, arg1, arg2, arg3, arg4, arg5);
        };
        EventMgr._instace = null;
        return EventMgr;
      }(cc.EventTarget);
      tv.EventMgr = EventMgr;
    })(tv = exports.tv || (exports.tv = {}));
    cc._RF.pop();
  }, {} ]
}, {}, [ "Game", "MyTest", "myWin", "tvEvent" ]);